<?php
declare (strict_types=1);

namespace app\controller\admin;

use app\common\controller\BaseController;
use app\model\admin\User as userModel;
use think\App;
use \Throwable;

class User extends BaseController
{
    protected $model;

    public function __construct(App $app, userModel $model)
    {
        parent::__construct($app);
        $this->model = $model;
    }

    /**
     * 列表查询
     * @return array
     */
    public function query()
    {
        $where = [];
        $page = input('page/d', 1);
        $pageSize = input('page_size/d', 20);
        $order = null;
        $fields = '*';
        return $this->model->getList($where, $fields, $order, $page, $pageSize);
    }

    /**
     * @return mixed
     * 用户登录
     */
    public function login()
    {
        return $this->model->doLogin($this->params);
    }

    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * 用户详情
     */
    public function detail()
    {
        $this->params['user_id'] = $this->memberId;
        return $this->model->getDetail($this->params);
    }
}
